package com.example.fraud;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;

@Slf4j
@Service
public record FraudReviewService(
        FraudCheckHistoryRepository fraudCheckHistoryRepository) {

    public Boolean isFraudulentCustomer(String customerEmail) {
        // 查询该email是否有欺诈历史记录
        List<FraudCheckHistory> histories = fraudCheckHistoryRepository
                .findAllByEmailAndIsFraudster(customerEmail, true);

        log.info("Fraud check customer with Email: {}, has {} fraud records.",
                customerEmail, histories.size());

        // 有欺诈记录返回true，否则返回false
        return !histories.isEmpty();
    }
}